<?php

namespace common\models\user;

use Yii;
use yii\behaviors\TimestampBehavior;


/**
 * This is the model class for table "{{%user_diary}}".
 *
 * @property integer $id
 * @property string $title
 * @property integer $type
 * @property string $content
 * @property string $tag
 * @property integer $createBy
 * @property string $createName
 * @property integer $is_valid
 * @property integer $created_at
 * @property integer $updated_at
 */
class UserDiary extends \common\models\BaseModels
{
    /**
     * default 
     */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'createdAtAttribute' => 'created_at',
                'updatedAtAttribute' => 'updated_at',
                'value'=> time(),
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%user_diary}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'createBy', 'created_at', 'updated_at'], 'required'],
            [['type', 'createBy', 'is_valid', 'created_at', 'updated_at'], 'integer'],
            [['title'], 'string', 'max' => 64],
            [['content'], 'string', 'max' => 512],
            [['tag', 'createName'], 'string', 'max' => 32],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app_table', 'ID'),
            'title' => Yii::t('app_table', '标题'),
            'type' => Yii::t('app_table', '日记类型'),
            'content' => Yii::t('app_table', '内容'),
            'tag' => Yii::t('app_table', '标签'),
            'createBy' => Yii::t('app_table', '创建人'),
            'createName' => Yii::t('app_table', '创建人'),
            'is_valid' => Yii::t('app_table', 'Is Valid'),
            'created_at' => Yii::t('app_table', '创建时间'),
            'updated_at' => Yii::t('app_table', '更新时间'),
        ];
    }
}
